unit adtmprfid;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 
  Buttons, ExtCtrls, ComCtrls, RzButton, StrUtils;

type
  Tadtmprfidfrm = class(TForm)
    Label1: TLabel;
    txttmprfid: TEdit;
    Label2: TLabel;
    txtprimalrfid: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    strtime: TDateTimePicker;
    endtime: TDateTimePicker;
    Label5: TLabel;
    txtpickername: TEdit;
    RzBitBtn1: TRzBitBtn;
    RzButton1: TRzButton;
    RzButton2: TRzButton;
    RzButton3: TRzButton;
    ListBox: TListBox;
    procedure RzButton2Click(Sender: TObject);
    procedure RzButton3Click(Sender: TObject);
    procedure RzButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure RzBitBtn1Click(Sender: TObject);
    procedure ListBoxClick(Sender: TObject);
    procedure txttmprfidKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  adtmprfidfrm: Tadtmprfidfrm;

implementation

{$R *.dfm}

uses includefile, dbmodule;

procedure Tadtmprfidfrm.RzButton2Click(Sender: TObject);
begin
  if ((Trim(txttmprfid.text)='') or (Trim(txtprimalrfid.Text)='')) then begin
    txttmprfid.SetFocus;  
    exit;
  end;
  modalresult:=mrok;
end;

procedure Tadtmprfidfrm.RzButton3Click(Sender: TObject);
begin
  modalresult:=mrcancel;
end;

procedure Tadtmprfidfrm.RzButton1Click(Sender: TObject);
var
  tmprfid:string;
begin
  if ((Trim(txttmprfid.text)='') or (Trim(txtprimalrfid.Text)='')) then exit;
  tmprfid:=RightStr('0000000000'+Trim(txttmprfid.text),RFIDLEN);
  if dbmodulefrm.tmpRfidExist(tmprfid) then begin
    Application.MessageBox('The TEMP RFID is exist,Please check it','Message',16);
    txttmprfid.text:='';
    Exit;
  end;
  modalresult:=mrYes;
end;

procedure Tadtmprfidfrm.FormCreate(Sender: TObject);
var
  i:integer;
begin
  Caption:=GetCaption('adtmprfidfrm',1000);
  for I:=0 to ComponentCount-1 do begin
    if Components[I] is TLabel then begin
      if 0<>TLabel(Components[I]).Tag then
        TLabel(Components[I]).Caption:=
                GetCaption('adtmprfidfrm',TLabel(Components[I]).Tag);
    end;
    if Components[I] is TRzButton then begin
      if 0<>TRzButton(Components[I]).Tag then
        TRzButton(Components[I]).Caption:=
                GetCaption('adtmprfidfrm',TRzButton(Components[I]).Tag);
    end;
  end;
  txttmprfid.MaxLength:=RFIDLen;
  rzbutton1.Hint:=Getcaption('Hints',101);
  rzbutton2.Hint:=Getcaption('Hints',102);
  strtime.DateTime :=now;
  endtime.DateTime :=now;
end;

procedure Tadtmprfidfrm.RzBitBtn1Click(Sender: TObject);
begin
  dbmodulefrm.getRFIDName(listbox.Items);
  listbox.Left:=6;
end;

procedure Tadtmprfidfrm.ListBoxClick(Sender: TObject);
begin
  txtprimalrfid.Text:=Trim(leftstr(listbox.Items.Strings[listbox.ItemIndex],10));
  txtpickername.Text:=Trim(Rightstr(listbox.Items.Strings[listbox.ItemIndex],20));
  listbox.Left:=600;
end;

procedure Tadtmprfidfrm.txttmprfidKeyPress(Sender: TObject; var Key: Char);
begin
  case key of
    '0'..'9',#$08:begin  end;
    else begin
      key:=#00;
      Application.MessageBox(pchar(GetCaption('MsgBox',107)),
                             pchar(GetCaption('MsgBox',106)),MB_ICONINFORMATION);
    end;
  end;
end;

end.
